Skip to content

feat(liquidity): add byAnchor method and endpoints - #198

Merged
Jagadeeshftw merged 1 commit into
AnchorNet-Org:mainfrom
Agencybuilds:feat/by-anchor-liquidity
Jul 26, 2026
Merged

feat(liquidity): add byAnchor method and endpoints#198
Jagadeeshftw merged 1 commit into
AnchorNet-Org:mainfrom
Agencybuilds:feat/by-anchor-liquidity

Conversation

@Agencybuilds

Copy link
Copy Markdown
Contributor

Closes #161

Description

This PR resolves the issue where LiquidityRepository exposed byAsset(asset) but had no symmetric byAnchor(anchor) to list every asset balance held by a single anchor, making it difficult for the routing layer to efficiently query an anchor's total balances.

Changes

  • LiquidityRepository: Added byAnchor(anchor: string): LiquidityEntry[] which mirrors the byAsset method.
  • LiquidityService: Added listByAnchor(anchor) method to fetch all balances for an anchor.
  • Routes: Added the GET /api/v1/liquidity/anchors/:anchor route to expose the functionality, carefully ordered to avoid shadowing the existing /:asset endpoint.
  • OpenAPI: Updated the OpenAPI specs in src/openapi.ts to document the new GET /api/v1/liquidity/anchors/{anchor} endpoint.
  • Tests: Added extensive test coverage in src/repositories/liquidityRepository.test.ts, src/services/liquidityService.test.ts, and src/routes/liquidity.test.ts.

Testing

  • Tests added verify byAnchor works correctly and returns the appropriate entries.
  • Verification ensures GET /api/v1/liquidity/anchors/:anchor does not conflict with GET /api/v1/liquidity/:asset.
  • Test suite (328 tests) passed successfully.

Security notes

No new write access added; this relies on an existing read-only filter pattern that exposes data already accessible (less efficiently) via the unfiltered endpoint.

@Jagadeeshftw
Jagadeeshftw merged commit 12e02d5 into AnchorNet-Org:main Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a LiquidityRepository.byAnchor(anchor) method to list every asset balance for one anchor

2 participants